/**
 *
 */
import Util;
import OpenApi;
import OpenApiUtil;
import EndpointUtil;

extends OpenApi;

init(config: OpenApi.Config){
  super(config);
  @endpointRule = '';
  
  checkConfig(config);
  @endpoint = getEndpoint('nbf', @regionId, @endpointRule, @network, @suffix, @endpointMap, @endpoint);
}

function getEndpoint(productId: string, regionId: string, endpointRule: string, network: string, suffix: string, endpointMap: map[string]string, endpoint: string) throws: string{
  if (!Util.empty(endpoint)) {
    return endpoint;
  }

  if (!Util.isUnset(endpointMap) && !Util.empty(endpointMap[regionId])) {
    return endpointMap[regionId];
  }
  return EndpointUtil.getEndpointRules(productId, regionId, endpointRule, network, suffix);
}
model AddRequest {
  x?: int32(name='x'),
  y?: int32(name='y'),
}

model AddResponseBody = {
  sum?: int32(name='sum'),
}

model AddResponse = {
  headers: map[string]string(name='headers'),
  body: AddResponseBody(name='body'),
}

async function add(request: AddRequest): AddResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return addWithOptions(request, headers, runtime);
}

async function addWithOptions(request: AddRequest, headers: map[string]string, runtime: Util.RuntimeOptions): AddResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.x)) {
    query.x = request.x;
  }
  if (!Util.isUnset(request.y)) {
    query.y = request.y;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('Add', '2021-08-23_17-52-51-578', 'HTTPS', 'GET', 'AK', `/kxFourTest/add`, 'json', req, runtime);
}

model NewTestApiRequest {
  input?: int32(name='input'),
}

model NewTestApiResponseBody = {
  result?: string(name='result'),
  current?: int32(name='current'),
  total?: long(name='total'),
  totalPage?: int32(name='totalPage'),
  success?: boolean(name='success'),
  pageSize?: int32(name='pageSize'),
  errorCode?: string(name='errorCode'),
  bizException?: boolean(name='bizException'),
  errorMsg?: string(name='errorMsg'),
}

model NewTestApiResponse = {
  headers: map[string]string(name='headers'),
  body: NewTestApiResponseBody(name='body'),
}

async function newTestApi(request: NewTestApiRequest): NewTestApiResponse {
  var runtime = new Util.RuntimeOptions{};
  var headers : map[string]string = {};
  return newTestApiWithOptions(request, headers, runtime);
}

async function newTestApiWithOptions(request: NewTestApiRequest, headers: map[string]string, runtime: Util.RuntimeOptions): NewTestApiResponse {
  Util.validateModel(request);
  var query : map[string]any= {};
  if (!Util.isUnset(request.input)) {
    query.input = request.input;
  }

  var req = new OpenApi.OpenApiRequest{ 
    headers = headers,
    query = OpenApiUtil.query(query),
  };
  return doROARequest('NewTestApi', '2021-08-23_17-52-51-578', 'HTTPS', 'POST', 'AK', `/newTestApi`, 'json', req, runtime);
}

